const path = require('path')
const common = require('./webpack.common')
const merge = require('webpack-merge')
const CopyWebpackPlugins = require('copy-webpack-plugin')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')

// merge内部会自动处理合并的逻辑
module.exports = merge(common, {
  mode: 'production',
  // 文件输出
  output: {
    // 打包输出的文件名
    filename: 'js/bundle.[contenthash:8].js',
    path: path.join(__dirname, 'dist'),
    publicPath: './'
  },
  plugins: [
    new CleanWebpackPlugin(),
    new CopyWebpackPlugins({
      patterns: ['public']
    })
  ]
})